home *** CD-ROM | disk | FTP | other *** search
/ HPAVC / HPAVC CD-ROM.iso / KMOUSE10.ZIP / TESTKMOU.PAS < prev   
Pascal/Delphi Source File  |  1989-10-05  |  2KB  |  76 lines

  1. Program testKmou;
  2. { program to test the operation of the keymouse unit }
  3. Uses DOS,CRT,KMouse;
  4. Const
  5.   HelloStr : String =
  6.                '**** KEYMOUSE DEMO PROGRAM ****';
  7.   ExitStr  : String =
  8.                'Press the [ESC] key to end the Demo';
  9.  
  10. Var Ch : Char;
  11.     X,Y : Word;
  12. {$F+}
  13. Function ScanKey : Char;
  14. {Reads a key from the keyboard and converts 2 scan codes into 1 char }
  15. { by adding 128 to the ordinal value }
  16. Var
  17.   Ch : Char;
  18. Begin
  19.   Ch := ReadKey;
  20.   if (Ch = #0) and KeyPressed Then
  21.     Begin
  22.       Ch := ReadKey;
  23.       if Ord(Ch) < 128 Then
  24.         Ch := Chr(Ord(Ch)+128);
  25.     End;
  26.     ScanKey := Ch;
  27. End;
  28.  
  29. Begin
  30. ClrScr;
  31. {  Set up the mouse the way we want it  }
  32. SetMouseMotion(MoveAll);        { All directions }
  33. SetMouseButtons($3B00, {F1}     { Refer to scancode table in Appendix C }
  34.                 $3C00, {F2}     { of Turbo Pascal Ref. manuals.         }
  35.                 $011B);{ESC}
  36. SetMouseDelay(3,1);             {Vertical & Horiz delays}
  37.  
  38. InitMouse(MouseLBReleased+MouseRBReleased+MouseMBReleased+MouseMoved);
  39.  {Left rel, Right rel, Mid rel, and Movement}
  40.  
  41.  
  42. X := 40; Y := 13;         { Initial Coordinates }
  43. GoToXY(40-(Length(HelloStr) Div 2), 1);
  44. Write(HelloStr);
  45. GotoXY(40-(Length(ExitStr) Div 2), 25);
  46. Write(ExitStr);
  47. GoToXY(X,Y);              { Place the cursor }
  48. Repeat
  49.   Ch := ScanKey;
  50.   Case Ch of
  51.   #32..#127 : Write(Ch);
  52.   #187      : {F1} Write('F1');
  53.   #188      : {F2} Write('F2');
  54.   #189      : {F3} Write('F3');
  55.  
  56.   #200      : {Up Cursor}
  57.               Begin
  58.                 If Y = 1 then Y := 25 Else Dec(Y);
  59.                 GoToXY(X,Y);
  60.               End;
  61.   #208      : {Down Cursor}
  62.               Begin
  63.                 If Y = 25 Then Y := 1 Else Inc(Y);
  64.                 GotoXY(X,Y);
  65.               End;
  66.   #203      : Begin  { Left Key }
  67.                 If X = 1 Then X := 80 Else Dec(X);
  68.                 GotoXY(X,Y);
  69.               End;
  70.   #205      : Begin  { Right Key }
  71.                 If X = 80 Then X := 1 Else Inc(X);
  72.                 GoToXY(X,Y);
  73.               End;
  74.   End; {Case}
  75. Until Ch = #27;
  76. End.